var express = require('express');
var router = express.Router();
var https = require('https');
const options = {
    hostname: 'www.daxunxun.com',
    port: 443, // https协议为443  如果是http协议 80
    path: '/douban?start=0&count=100',
    method: 'GET'
}

/* GET users listing. */
router.get('/', function(req, res, next) {
    const req1 = https.request(options, (res1) => {
        let str = ''
      
        res1.on('data', (d) => {
          str += d;
        });
        res1.on('end', () => {
            console.log(typeof str)
            // res.send(str)
            res.render('douban', {result: JSON.parse(str)})
        })
      });
      
      req1.on('error', (e) => {
        console.error(e);
      });
      req1.end();
//   res.send('respond with a resource');
});

module.exports = router;
